package com.decent.ejfadmin.configure.dao;

import com.decent.ejfadmin.configure.entity.UserPlatformBanner;
import com.decent.ejfadmin.configure.entity.dto.UserPlatformBannerDTO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * describe:会员系统banner
 *
 * @author 陈豆豆
 * @date 2019/08/10
 */
@Mapper
@Repository
public interface BannerConfigDao {
    /**
     * banner列表
     *
     * @param userPlatformBanner
     * @return
     */
    @SelectProvider(method = "listBanner", type = BannerConfigDaoProvider.class)
    List<UserPlatformBanner> listBanner(@Param("userPlatformBanner") UserPlatformBanner userPlatformBanner);

    /**
     * 新增Banner
     *
     * @param userPlatformBanner
     * @return
     */
    @Insert("insert into yuhuang_user_platform_banner" +
            "(picture_url," +
            "picture_name," +
            "picture_key," +
            "gmt_create," +
            "remark," +
            "sort," +
            "image_binary)" +
            "values(" +
            "#{userPlatformBanner.pictureUrl}," +
            "#{userPlatformBanner.pictureName}," +
            "#{userPlatformBanner.pictureKey}," +
            "now()," +
            "#{userPlatformBanner.remark}," +
            "#{userPlatformBanner.sort}," +
            "#{userPlatformBanner.imageBinary})")
    int addBanner(@Param("userPlatformBanner") UserPlatformBannerDTO userPlatformBanner);

    /**
     * 修改Banner
     *
     * @param userPlatformBanner
     * @return
     */
    @UpdateProvider(method = "updateBanner",type = BannerConfigDaoProvider.class)
    int updateBanner(@Param("userPlatformBanner") UserPlatformBannerDTO userPlatformBanner);

    /**
     * 删除Banner
     *
     * @param id
     * @return
     */
    @Delete("delete from yuhuang_user_platform_banner where id=#{id}")
    int deleteBanner(@Param("id") Integer id);

    /**
     * 根据排序获取banner信息
     *
     * @param sort
     * @return
     */
    @Select("select * from yuhuang_user_platform_banner where sort=#{sort}")
    UserPlatformBanner getBannerBySort(@Param("sort") Integer sort);

    /**
     * 根据主键获取banner信息
     *
     * @param id
     * @return
     */
    @Select("select * from yuhuang_user_platform_banner where id=#{id}")
    UserPlatformBanner getBannerById(@Param("id") Integer id);
}
